/*****************************************************************************
 * $LastChangedDate: 2011-04-23 21:07:07 -0400 (Sat, 23 Apr 2011) $
 * @file
 * @author  Jim E. Brooks
 * @brief   C++ streams.
 *//*
 * LEGAL:   COPYRIGHT (C) 2007 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE VERSION 2 (GPL 2).
 *****************************************************************************/

#ifndef BASE_STREAM_FUNCS_HH
#define BASE_STREAM_FUNCS_HH 1

#include <iostream>
#include <iomanip>
#include <streambuf>
#include <fstream>

namespace base {

//------------------------------------------------------------------------------
// Helpers for C++ streams.
// bool StreamGood( std::ios& s );  // just use stream.good() (hi-freq)
//------------------------------------------------------------------------------

/*******************************************************************************
 * Open a stream to a file.
 * @param   fs
 *          File stream.
 * @param   bits
 *          Open for reading and/or writing.
 * @param   filename
 * @return  False if stream error.
 *******************************************************************************/
bool StreamOpen( std::fstream& fs, std::ios::openmode bits, const string& filename );

/*******************************************************************************
 * Read all chars to EOL.
 * @return False if stream error.
 *******************************************************************************/
bool StreamReadLine( std::istream& strm, string& line );

/*******************************************************************************
 * Jump to the next line.
 * @return False if stream error.
 *******************************************************************************/
bool StreamToNextLine( std::istream& strm );

/*******************************************************************************
 * Peek input stream.
 * @return True if word is in input stream.
 *******************************************************************************/
bool StreamPeek( std::istream& strm, const string& word );

} // namespace base

#endif // BASE_STREAM_FUNCS_HH
